(function() {
	/*
	 * Title-Map
	 */
	eventManager.after("AppReady", function() {
		var _set_title = Path.setTitle;
		Path.setTitle = function() {
			App.set("$Loc.document_title", _set_title());
		};
		App.set("$Loc.document_title", Path.document_title);
		// 退出登陆
		App.set("$Event.top.loginout", function() {
			coAjax.post("http://apibbs.shengyi8888.com/user/loginout", function() {
				alert("success", "您已退出登陆");
				App.set("loginer", "");
				Cookies.set("loginer", null);
			}, function(err, errMsg, a) {
				console.log(a);
			});
		});
		Path.on("*", function() {
			// 获取登陆用户
			if (!App.get("loginer") && Cookies.get("loginer") && location.href.indexOf("/admin/") < 0) {
				coAjax.post("http://apibbs.shengyi8888.com/user/loginer", function(result) {
					App.set("loginer", result);
				}, function(err, errMsg) {
					Cookies.set("loginer", null);
					console.log(errMsg);
				});
			}
		});
	});
	var api_root = "http://121.40.72.93:4100/qaq";
	window.public_api = {
		admin: {
			login: api_root + "/admin/login",
			loginer: api_root + "/admin/loginer",
			create: api_root + "/admin/create",
			loginout: api_root + "/admin/loginout"
		},
		section: {
			get: {
				byid: api_root + "/section/by_id/:section_id/with_news_list",
				list_all: api_root + "/section/list_all"
			},
			create: api_root + "/section/create",
			update: api_root + "/section/update",
			remove: api_root + "/section/remove/"
		},
		news: {
			get: {
				detail_by_id: api_root + "/news/detail_by_id/",
				list_by_section_id: api_root + "/news/list_by_section_id/",
				list_all: api_root + "/news/list_all"
			},
			create: api_root + "/news/create",
			update: api_root + "/news/update",
			remove: api_root + "/news/remove/"
		},
		banner: {
			get: {
				all: api_root + "/banner/all"
			},
			create: api_root + "/banner/create",
			update: api_root + "/banner/update",
			remove: api_root + "/banner/remove/"
		}
	};
}());